import type { FormSchemaGetter } from '#/adapter/form';
import type { VxeGridProps } from '#/adapter/vxe-table';

export const querySchema: FormSchemaGetter = () => [
  {
    component: 'Input',
    fieldName: 'cno',
    label: '坐席工号',
  },
  {
    component: 'UserListSelect',
    fieldName: 'userId',
    label: '呼叫人员',
  },
];

export const columns: VxeGridProps['columns'] = [
  {
    field: 'identifier',
    title: '企业编号',
  },
  {
    field: 'cno',
    title: '坐席工号',
  },
  {
    field: 'password',
    title: '坐席密码',
  },
  {
    field: 'bindTel',
    title: '绑定电话',
  },
  {
    field: 'userName',
    title: '呼叫人员',
  },
  {
    field: 'allocationType',
    title: '分配模式',
    slots: { default: 'allocationType' },
  },
  {
    field: 'remark',
    title: '备注',
    showOverflow: true,
  },
  {
    field: 'updateTime',
    title: '更新时间',
    width: 180,
  },
  {
    field: 'action',
    fixed: 'right',
    slots: { default: 'action' },
    title: '操作',
    resizable: false,
    width: 'auto',
  },
];

export const drawerSchema: FormSchemaGetter = () => [
  {
    label: 'ID',
    fieldName: 'id',
    component: 'Input',
    dependencies: {
      show: () => false,
      triggerFields: [''],
    },
  },
  {
    component: 'Input',
    fieldName: 'identifier',
    label: '企业编号',
    componentProps: {
      disabled: true,
    },
    defaultValue: 'ites',
    help: '天润融通固定的企业客户编号',
    rules: 'required',
  },
  {
    component: 'Input',
    fieldName: 'cno',
    label: '坐席号',
    rules: 'required',
  },
  {
    component: 'InputPassword',
    fieldName: 'password',
    label: '坐席密码',
    rules: 'required',
  },
  {
    component: 'Input',
    fieldName: 'bindTel',
    label: '绑定电话',
    help: '电话号码和坐席号请保持一致',
    rules: 'required',
  },
  {
    component: 'RadioGroup',
    fieldName: 'bindType',
    label: '绑定类型',
    componentProps: {
      disabled: true,
      buttonStyle: 'solid',
      options: [{ label: '软电话', value: 3 }],
      optionType: 'button',
    },
    defaultValue: 3,
    help: '默认为软电话类型，前端页面接入SDK的方式',
    rules: 'selectRequired',
  },
  {
    component: 'UserListSelect',
    fieldName: 'userId',
    label: '呼叫人员',
    // rules: 'selectRequired',
    help: '为蜂巢账号绑定坐席账号后，才能使用云呼叫功能',
  },
  {
    component: 'RadioGroup',
    fieldName: 'allocationType',
    label: '分配模式',
    dependencies: {
      if: (values) => values?.userId,
      triggerFields: ['userId'],
    },
    componentProps: {
      buttonStyle: 'solid',
      options: [
        { label: '固定', value: 1 },
        { label: '自动', value: 2 },
      ],
      optionType: 'button',
    },
    // defaultValue: 1,
    help: '固定：呼叫人员始终使用绑定的坐席账号\n自动：系统将自动为呼叫人员分配当前空闲可用的坐席账号',
    rules: 'selectRequired',
  },
  {
    component: 'Textarea',
    fieldName: 'remark',
    label: '备注',
  },
];
